package controllers

import (
	"fmt"
	"github.com/astaxie/beego"
	m"xmy/models/admin"


)

type SendController struct {
	beego.Controller
}

//返回值 封装为 JSON 格式
func (this *SendController) Rsp(status bool, str string) {
	this.Data["json"] = &map[string]interface{}{"status": status, "info": str}
	this.ServeJSON()
}

func (c *SendController)  SendConfigManage() {
	fmt.Println("进来--发送设置--控制器啦！")
	send:= m.QuerySend()
	fmt.Println("send................................",send)
	//获取第一个silence 里面的值
	c.Data["Cmpname"] = send[0]["Cmpname"]
	c.Data["Cmptel"] = send[0]["Cmptel"]
	c.Data["Cmpmail"] = send[0]["Cmpmail"]
	c.Data["Sendtime"] = send[0]["Sendtime"]
	c.Data["Errtimes"] = send[0]["Errtimes"]
	c.TplName = "system/sendConfig.html"
}


func (c *SendController)  SendConfigManageDetail() {
	fmt.Println("进来--发送详情--控制器啦！")
	send:= m.QuerySend()
	c.Data["json"] = &map[string]interface{}{"rows": &send}
	c.ServeJSON()
	return
}


func (c *SendController)  SendConfigManageEdit() {
	fmt.Println("进来--发送修改--控制器啦！")
	g := m.Send{}


	if err := c.ParseForm(&g); err != nil {
		c.Rsp(false, err.Error())
		return
	}
	id, err := m.SendEdit(&g)
	if err == nil && id > 0 {
		c.Rsp(true, "Success")
		return
	} else {
		c.Rsp(false, err.Error())
		return
	}
}


func (c *SendController)  TestSql() {
	maps:= m.Test111()
	fmt.Println("TestSql................................",maps)

}
